//
//  MBProgressHUD+MBHud.m
//  ltsport
//
//  Created by iOS on 2020/7/9.
//  Copyright © 2020 MengBao. All rights reserved.
//

#import "MBProgressHUD+MBHud.h"

@implementation MBProgressHUD (MBHud)

+ (void)showMessage:(NSString *)message toView:(nullable UIView *)view completionBlock:(nullable void (^)(void))completionBlock {
    if (view == nil) view = [[UIApplication sharedApplication].windows lastObject];
    
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
    hud.label.text = message;
    hud.label.numberOfLines = 0;
    hud.mode = MBProgressHUDModeText;
    hud.label.textColor = UIColor.whiteColor;
    hud.bezelView.style = MBProgressHUDBackgroundStyleSolidColor;
    hud.bezelView.backgroundColor = UIColor.blackColor;
    [hud hideAnimated:YES afterDelay:1.5];
    hud.completionBlock = completionBlock;
}

+ (void)showMessage:(NSString *)message toView:(nullable UIView *)view
{
    if (view == nil) view = [[UIApplication sharedApplication].windows lastObject];
    
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
    hud.label.text = message;
    hud.label.numberOfLines = 0;
    hud.mode = MBProgressHUDModeText;
    hud.label.textColor = UIColor.whiteColor;
    hud.bezelView.style = MBProgressHUDBackgroundStyleSolidColor;
    hud.bezelView.backgroundColor = [UIColor getColorWithHex:@"#252525"];
    [hud hideAnimated:YES afterDelay:1.5];
}

+ (void)showNetWorkErrorToView:(nullable UIView *)view {
    if (view == nil) view = [[UIApplication sharedApplication].windows lastObject];
    
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
    hud.label.text = @"网络连接超时";
    hud.mode = MBProgressHUDModeText;
    hud.label.textColor = UIColor.whiteColor;
    hud.bezelView.style = MBProgressHUDBackgroundStyleSolidColor;
    hud.bezelView.backgroundColor = UIColor.blackColor;
    [hud hideAnimated:YES afterDelay:1.5];
}

@end
